<template>
  <div>
    <!-- 面包屑导航 -->
    <breadcrumb>
      <span slot="first">首页</span>
      <span slot="second">权限管理</span>
      <span slot="third">权限列表</span>
    </breadcrumb>
    <!-- 卡片区域 -->
    <el-card>
      <!-- 表格区域 -->
      <el-table :data="rightsList" border>
        <el-table-column type="index"></el-table-column>
        <el-table-column prop="authName" label="权限名称"></el-table-column>
        <el-table-column prop="path" label="权限路径"></el-table-column>
        <el-table-column prop="level" label="权限等级">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.level === '0'">一级</el-tag>
            <el-tag type="success" v-else-if="scope.row.level === '1'">二级</el-tag>
            <el-tag type="danger" v-else>三级</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
import Breadcrumb from '@/components/common/Breadcrumb.vue';
import { request } from '@/network/request'
export default {
  name: "Rights",
  components: {
    Breadcrumb
  },
  data() {
    return {
      rightsList: []
    }
  },
  created() {
    this.getRightsList()
  },
  methods: {
    // 获取权限列表
    async getRightsList() {
      const { data: res } = await request({
        url: "rights/list"
      })
      if (res.meta.status !== 200) return this.$message.error("获取权限列表失败")
      this.rightsList = res.data
    }

  },
}
</script>

<style lang='less' scoped>

</style>